"""
file: test_screen.py
Author: 城下秋草
Date: 2024/12/10
Desc: 截图和录屏
"""
from playwright.sync_api import sync_playwright, expect

playwright = sync_playwright().start()
browser = playwright.chromium.launch(
    headless=False,
    slow_mo=500,
    args=["--window-position=1024,-850"]
)

context = browser.new_context(record_video_dir='videos/',
                              record_video_size={'width':800,'height':600})
page = context.new_page()
page.goto('https://demoqa.com/dynamic-properties')

page.screenshot(path='1.png')
page.locator('#visibleAfter').click()
page.screenshot(path='2.png')
page.screenshot(path='3.png',full_page=True)

page.screenshot(path='4.png',mask=[page.locator('#enableAfter')])
page.locator('#colorChange').screenshot(path='5.png')

context.close()
browser.close()
playwright.stop()
